package com.vcredit.creditcat.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.vcredit.creditcat.model.AuthProccess;
import com.vcredit.creditcat.persistence.AuthProccessExtMapper;
import com.vcredit.creditcat.persistence.base.AuthProccessMapper;

/**
 * 
 **/
@Service
public class AuthProccessService {
	@Autowired
	private AuthProccessMapper mapper;
	@Autowired
	private AuthProccessExtMapper extMapper;

	public void insert(AuthProccess obj) {
		mapper.insert(obj);
	}

	public void update(AuthProccess obj) {
		mapper.update(obj);
	}

	public List<AuthProccess> findAll() {
		return mapper.findAll();
	}

	private List<AuthProccess> find(AuthProccess obj) {
		return mapper.find(obj);
	}
		
	public List<AuthProccess> findMax(AuthProccess obj) {
		return mapper.findMax(obj);
	}
	

	public List<AuthProccess> findByCustId(Long custId) {
		AuthProccess param = new AuthProccess();
		param.setCustId(custId);
		return find(param);
	}

	public AuthProccess findByProcessId(Long proccessId) {
		return mapper.findById(proccessId);
	}

	public AuthProccess createProcess(Long custId,Integer successCode) {
		AuthProccess process = new AuthProccess();
		process.setSuccessCode(successCode);
		process.setCustId(custId);
		mapper.insert(process);
		return process;
	}

	public AuthProccess findById(Long processId) {
		return mapper.findById(processId);
	}
	
	public AuthProccess findByIdForUpdate(Long processId){
		return extMapper.findByIdForUpdate(processId);
	}
	
	public void updateProcess(AuthProccess authProccess){
		extMapper.updateProcess(authProccess);
	}
}